#include "cmmdc.h"
cmmdc::sirIntreg(int q[100])
{
	for (int i=0; i<100;i++) 
	this->q[i]=q[i];
}
int cmmdc::getElem(int i)
{
	return this->v[i];
}
int cmmdc::nrElem()
{
	int i=0;
	while (this->getElem(i)!=0) 
		i++;
	return i;
}
int cmmdc::cmmdc(int a, int b)
{
	while(a!=b)
	{
	if(a>b) a=a-b;
	else b=b-a;
	}
	return a;
}
int cmmdc::cmmdc()
{
	int n=this->nrElem(),j,cmmdc,a,b;
	cmmdc=getElem(0);
	for(int i=0;i<n-1;i++)
	{
		j=i+1;
		a=this->getElem(i);
		b=this->getElem(j);
		while(a!=b)
		{
			if(a>b) a=a-b;
			else b=b-a;
		}
		if (cmmdc>a)
			cmmdc=a;
	}
	return cmmdc;
}
